﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 图书借阅系统
{
    public partial class 读者注册 : System.Web.UI.Page
    {
        string s = System.Configuration.ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text.Trim();
            string pwd = TextBox2.Text.Trim();
            if (name == "" || pwd == "")
            {
                Label1.Text = "用户姓名或密码不能为空！请确认！";
            }
            else
            {
                using (SqlConnection con = new SqlConnection(s))
                {
                    con.Open();
                    string str = string.Format("INSERT INTO 用户 VALUES ('{0}','{1}')", name, pwd);
                    Session["userID"] = Convert.ToInt32(Connection.Count(str, 0));
                    con.Close();
                }
                TextBox1.Text = "";
                TextBox2.Text = "";
                Label1.Text = "注册成功！请记住您的登录id（即读者号）：" + Session["userID"] + "！";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            Label1.Text = "";
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("系统主页.aspx");
        }
    }
}